﻿using System.Collections.Generic;

namespace MyMenu.action
{
   public class ShowMenu : AbstractAction
    {

       public List<Action> ListActions = new List<Action>();
       
       public Action[] actions
        {
            set
            {
                ListActions = new List<Action>(value);
            }
            get
            {
                return ListActions.ToArray();
            }
        }

       public void AddAction(Action action)
       {
           ListActions.Add(action);
       }


       public void RemoveAction(Action action)
       {
           ListActions.Remove(action);
       }

        public ShowMenu()
        {
           
        }

        public override void execute() 
        {
            int result = GuiFactory.toGUIDialogMenu(this);
            if (result >= 0)
            {
                actions[result - 1].execute();
            }
           
        }
    }
}
